package DRCOMM;

import java.util.ArrayList;
import java.util.List;
import java.util.Map;

public class record_data_set{

    public List<String> columns=new ArrayList<String>();
    public List<Map<String,String>> datas=new ArrayList<Map<String,String>>();
    public int count=0;

    public static String get_answer_json_str(int code,String msg,record_data_set rds){
        dr_ajax_answer daa=new dr_ajax_answer(code, msg);
        daa.set_data(rds.datas);
        daa.count=rds.count;
        daa.etc=rds.columns;
        return daa.json_string();
    }

    public void report(){
        System.out.println("columns:");
        for(String col:columns){
            System.out.println(col);
        }
        System.out.println("datas:");
        int count=0;
        for(Map<String,String> data:datas){
            for(String key:data.keySet()){
                System.out.print(data.get(key)+"\t");
            }
            System.out.println();
            count++;
            if(count>=10) break;
        }
        System.out.println("count:"+count);
    }

    public void report(int limit){
        System.out.println("columns:");
        for(String col:columns){
            System.out.print(col+"\t");
        }
        System.out.println("datas:");
        int count=0;
        for(Map<String,String> data:datas){
            for(String key:data.keySet()){
                System.out.print(key+":"+data.get(key)+"\t");
            }
            System.out.println();
            count++;
            if(count>=limit) break;
        }
        System.out.println("count:"+count);
    }

}